package com.lovo.service.impl;

import com.lovo.bean.CourseBean;
import com.lovo.dao.ICourseDAO;
import com.lovo.service.ICourseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class CourseServiceImpl implements ICourseService {
    @Resource
    private ICourseDAO courseDAO;

    @Override
    public List selectAll() {
        return courseDAO.findAll();
    }

    @Override
    public CourseBean selectById(Long id) {
        return courseDAO.findById(id).get();
    }

    @Override
    public void add(CourseBean courseBean) {
        courseDAO.save(courseBean);
    }

    @Override
    public void update(CourseBean courseBean) {
        courseDAO.save(courseBean);
    }

    @Override
    public void delete(Long id) {
        courseDAO.deleteById(id);
    }

}
